package cn.agiledata.bank.wap.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.PropertyUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import cn.agiledata.bank.common.service.ICommonService;
import cn.agiledata.bank.common.servlet.InitForString;
import cn.agiledata.bank.hibernateBean.SubAccount;
import com.vnv.infrastructure.exception.IPBException;

public class CommonAction extends WapBaseAction {
	/**
	 * 转发页面
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws IPBException
	 * @throws Exception
	 */
	public ActionForward toPage(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response)throws IPBException, Exception {
		
		
		String subAccountId = (String)PropertyUtils.getSimpleProperty(form, "subAccountId");
		String accountId = (String)PropertyUtils.getSimpleProperty(form, "accountId");
		String page = (String)PropertyUtils.getSimpleProperty(form, "page");
		ICommonService service = getCommonService();
		SubAccount subAccount = service.getSubAccount(subAccountId);
		
		List bankList = (List)InitForString.dataDictMap.get("BANK_INFO");
		
		request.setAttribute("subAccountId",subAccountId);
		request.setAttribute("accountId",accountId);
		request.setAttribute("subAccountBalance",subAccount.getAccountBalance().getBalance().toString());
		request.setAttribute("bankList",bankList);
		request.getRequestDispatcher(page).forward(request,response);
		return null;
	}
}
